package com.xc.h05.service.lishenao.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xc.h05.entity.Free;
import com.xc.h05.entity.User;
import com.xc.h05.mapper.FreeMapper;
import com.xc.h05.service.lishenao.FreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class FreeServiceImpl implements FreeService {
    @Autowired
    private FreeMapper freeMapper;
    @Override
    public PageInfo<Free> selectAll(Integer pageNum, Integer pageSize, Free free) {
        PageHelper.startPage(pageNum, pageSize);
        List<Free> freeList = freeMapper.selectAllByname(free);
        return new PageInfo<>(freeList);
    }

    @Override
    public int insert(Free free) {
        free.setCreatetime(new Date());
        return freeMapper.insert(free);
    }

    @Override
    public int delete(Long id) {
        return freeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(Free free) {
        free.setCreatetime(new Date());
        return freeMapper.updateByPrimaryKey(free);
    }

    @Override
    public Free selectById(Long id) {
        return freeMapper.selectByPrimaryKey(id);
    }

}
